home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / DCLAP 6d / dclap6d / network / nsclilib / ni_types.h < prev   
Text File  |  1996-07-05  |  12KB  |  253 lines

  1. /*      
  2. * ===========================================================================
  3. *
  4. *                            PUBLIC DOMAIN NOTICE                          
  5. *               National Center for Biotechnology Information
  6. *                                                                          
  7. *  This software/database is a "United States Government Work" under the   
  8. *  terms of the United States Copyright Act.  It was written as part of    
  9. *  the author's official duties as a United States Government employee and 
  10. *  thus cannot be copyrighted.  This software/database is freely available 
  11. *  to the public for use. The National Library of Medicine and the U.S.    
  12. *  Government have not placed any restriction on its use or reproduction.  
  13. *                                                                          
  14. *  Although all reasonable efforts have been taken to ensure the accuracy  
  15. *  and reliability of the software and data, the NLM and the U.S.          
  16. *  Government do not and cannot warrant the performance or results that    
  17. *  may be obtained by using this software or data. The NLM and the U.S.    
  18. *  Government disclaim all warranties, express or implied, including       
  19. *  warranties of performance, merchantability or fitness for any particular
  20. *  purpose.                                                                
  21. *                                                                          
  22. *  Please cite the author in any work or product based on this material.   
  23. *
  24. * ===========================================================================
  25. *
  26. * File Name:    ni_types.h
  27. *
  28. * Author:       Beatty, Gish
  29. *
  30. * Version Creation Date:        1/1/92
  31. *
  32. * $Revision: 4.0 $
  33. *
  34. * File Description: 
  35. *
  36. *
  37. * Modifications:  
  38. * --------------------------------------------------------------------------
  39. * Date     Name        Description of modification
  40. * -------  ----------  -----------------------------------------------------
  41. * 5/12/92  Epstein     Converted tabs to spaces
  42. *
  43. *
  44. * ==========================================================================
  45. *
  46. *
  47. * RCS Modification History:
  48. * $Log: ni_types.h,v $
  49.  * Revision 4.0  1995/07/26  13:56:32  ostell
  50.  * force revision to 4.0
  51.  *
  52.  * Revision 1.19  1995/05/24  12:09:04  epstein
  53.  * add support for tracking of how many times a client IP has used a service within a time interval
  54.  *
  55.  * Revision 1.18  95/05/17  17:52:51  epstein
  56.  * add RCS log revision history
  57.  * 
  58. */
  59.  
  60. #ifndef _NI_TYPES_
  61. #define _NI_TYPES_
  62.  
  63. #include <ncbi.h>
  64. #include <asn.h>
  65.  
  66. #define NI_Handle       MHandle                 /* for API use */
  67. #define NI_HandPtr      MHandPtr                /* for API use */
  68. #define NI_Request      Request                 /* for API use */
  69. #define NI_ReqPtr       ReqPtr                  /* for API use */
  70.  
  71. #define INETADDR_SIZ    16                      /* of the form 255.255.255.255 */
  72.  
  73. #define NI_ConnState enum NIConState
  74. NI_ConnState {
  75.         NI_ERROR_COND = 0,
  76.         NI_CREATED,
  77.         NI_BOUND,
  78.         NI_CONNECTED,
  79.         NI_DISCARD,             /* disconnect pending (requested) */
  80.         NI_DISCONNECTED
  81. };
  82.  
  83. typedef struct Node PNTR NodePtr;
  84. typedef struct Node {
  85.         VoidPtr         elem;           /* pointer to the element */
  86.         NodePtr         last;           /* previous element */
  87.         NodePtr         next;           /* next element */
  88. } Node;
  89.  
  90. typedef Int4 (LIBCALLBACK *NI_ReadFilt) PROTO((VoidPtr mh, CharPtr buf, int bytesread, int len, CharPtr PNTR extra_buf, Int4Ptr extra_buf_len));
  91. typedef Int4 (LIBCALLBACK *NI_WriteFilt) PROTO((VoidPtr mh, CharPtr buf, int len, CharPtr tmpbuf));
  92. typedef void (LIBCALLBACK *NI_TimeoutHook) PROTO((Pointer p));
  93.  
  94. typedef struct encr {
  95.         VoidPtr         desWriteContext; /* really a DES_CBC_CTX structure */
  96.         VoidPtr         desReadContext;  /* really a DES_CBC_CTX structure */
  97.         Uint1           encrType;
  98.         Int1            state;
  99.         Int2            numDeferredBytes;
  100.         Int2            realDataLeft;
  101.         Int2            bytesToRead;
  102.         Uchar           deferredData[15];
  103.         NI_WriteFilt    write_filter;    /* output filter routine */
  104.         NI_ReadFilt     read_filter;     /* input filter routine */
  105. } NI_EncrData, PNTR NI_EncrDataPtr;
  106.  
  107.  
  108. typedef struct MHandle {
  109.         CharPtr         hostname;       /* name of peer machine */
  110.         Uint4           conid;          /* unique connection id number */
  111.         Uint4           seqno;          /* unique message number */
  112.         NI_ConnState    state;          /* of connection - bound, connected, etc. */
  113.         int             sok;            /* the socket or file descriptor */
  114.         int             r_timeout;      /* read timeout value in seconds */
  115.         int             w_timeout;      /* write timeout value in seconds */
  116.         Uint4           peer;           /* Internet address of peer */
  117.         AsnIoPtr        raip;           /* ASNtool IO read pointer */
  118.         AsnIoPtr        waip;           /* ASNtool IO write pointer */
  119.         Boolean         longjump;       /* TRUE if OK to use longjump (servers) */
  120.         time_t          access_time;    /* time stamp of last access */
  121.         Boolean         unblocked_mode; /* is this interface "unblocked" ? */
  122.         Boolean         have_blocked;   /* have we blocked reading this msg? */
  123.         int             num_queued_bytes; /* amt of queued data for this msg */
  124.         int             cur_index;      /* current index for reading queue */
  125.         NodePtr         queued_data_list; /* queued data for this msg */
  126.         VoidPtr         extra_proc_info; /* extra processing info, used externally */
  127.         NI_WriteFilt    write_filter;    /* output filter routine */
  128.         NI_ReadFilt     read_filter;     /* input filter routine */
  129.         Boolean         write_filt_pass_thru; /* write filter is pass-thru */
  130.         Boolean         read_filt_pass_thru; /* read filter is pass-thru */
  131.         NI_TimeoutHook  readTimeoutHook; /* hook for read timeout expiration */
  132.         NI_TimeoutHook  writeTimeoutHook; /* hook for write tmout expiration */
  133.         NodePtr         readTimer;
  134.         NodePtr         writeTimer;
  135.         Boolean         isBrokered;
  136.         Uint2           brokeredPort;
  137.         NI_EncrDataPtr  encryption;
  138.         Uint2           connectDelay;
  139. } MHandle, PNTR MHandPtr;
  140.  
  141. typedef enum _NetServHookCode_ {
  142.         NetServHook_dispconn = 1,
  143.         NetServHook_svcreq,
  144.         NetServHook_svcdisconn,
  145.         NetServHook_dispdisconn,
  146.         NetServHook_read,
  147.         NetServHook_write
  148. } NI_NetServHookCode;
  149.  
  150. typedef void (LIBCALLBACK *NI_NetServHook) PROTO((NI_HandPtr, NI_NetServHookCode, int));
  151.  
  152.  
  153. typedef struct NICatalog {
  154.         Uint4           seqno;
  155.         CharPtr         motd;
  156.         NodePtr         toolsetL;
  157. } NICatalog, PNTR NICatalogPtr;
  158.  
  159. typedef struct NIRegion {
  160.         CharPtr         regionName;
  161.         Uint2           priorityDelta; /* incentive to clients in that region */
  162. } NIRegion, PNTR NIRegionPtr;
  163.  
  164. typedef struct NIToolset {
  165.         CharPtr         host;
  166.         CharPtr         motd;
  167.         NodePtr         services;
  168.         NodePtr         resources;
  169.         NodePtr         regions;
  170. } NIToolset, PNTR NIToolsetPtr;
  171.  
  172. typedef struct NIService {
  173.         CharPtr         name;           /* name of service */
  174.         Uint2           minVersion;
  175.         Uint2           maxVersion;     /* NULL if infinite */
  176.         Uint2           id;             /* ID that is unique on host */
  177.         Uint2           priority;       /* priority of service */
  178.         CharPtr         group;          /* group with access to resource */
  179.         CharPtr         descrip;        /* description of service */
  180.         NodePtr         typeL;          /* list of res types supported by svc */
  181.         NodePtr         subSetList;     /* svcs of which this supports a subset */
  182.         NodePtr         superSetList;   /* svcs of which this supports a superset */
  183.         Uint2           priorityTimeout; /* timeout by which dispd must hear  */
  184.         Uint2           priorityPenalty; /* resp from ncbid or impose penalty */
  185.         Boolean         encryptionSupported; /* does this service support encryption? */
  186.         Uint2           trackingPeriod; /* time over which Dispatcher track(s/ed) this service */
  187.         Uint4           trackingCount; /* # service requests for this service&IP during tracking-period */
  188. } NIService, PNTR NISvcPtr;
  189.  
  190. typedef struct NIResource {
  191.         CharPtr         name;
  192.         CharPtr         type;           /* same as a service name ? */
  193.         Uint2           minVersion;
  194.         Uint2           maxVersion;
  195.         Uint2           id;             /* ID that is unique on host */
  196.         CharPtr         group;          /* group with access to resource */
  197.         CharPtr         descrip;        /* description of resource */
  198. } NIResource, PNTR NIResPtr;
  199.  
  200. typedef struct NI_Uid {
  201.         CharPtr         username;       /* kerberos principle */
  202.         CharPtr         group;          /* kerberos instance */
  203.         CharPtr         domain;         /* kerberos realm */
  204. } NI_Uid, PNTR NI_UidPtr;
  205.  
  206. typedef struct NI_Dispatcher {
  207.         struct Request PNTR reqResponse;     /* ptr to request struct with actual services/resources used */
  208.         CharPtr          dispHostName;
  209.         CharPtr          dispServiceName;
  210.         Int4             dispSerialNo;
  211.         Char             localHostAddr[INETADDR_SIZ];  /* Internet address of client */
  212.         NI_HandPtr       dispHP;             /* handle for dispatcher */
  213.         NI_HandPtr       svcsHP;             /* handle for incoming services */
  214.         Uint2            clientPort;
  215.         NI_UidPtr        identity;           /* client identity struct */
  216.         int              dispTimeout;        /* timeout when communicating w/dispatcher */
  217.         Int2             loport;             /* range of client ports to bind */
  218.         Int2             hiport;             /* range of client ports to bind */
  219.         Int2             referenceCount;     /* # of services connected via this dispatcher */
  220.         Boolean          someBrokered;       /* some services are brokered */
  221.         Boolean          brokeredDummy;      /* indicates that this is a dummy */
  222.         ValNodePtr       encryptInfo;        /* encryption information, or NULL */
  223.         Boolean          useSocks;           /* client should use SOCKS */
  224.         CharPtr          adminInfo;          /* info. regarding administrator */
  225.         CharPtr          motd;               /* message of the day for user */
  226. } NI_Dispatcher, PNTR NI_DispatcherPtr;
  227.  
  228. typedef struct Request {
  229.         CharPtr         clientAddr;
  230.         Uint2           clientPort;
  231.         NISvcPtr        service;        /* ptr to a service (NOT a node) */
  232.         NodePtr         resourceL;      /* ptr to list of resources */
  233.         NI_DispatcherPtr dispatcher;    /* dispatcher on which req is made */
  234. } Request, PNTR ReqPtr;
  235.  
  236. typedef struct NI_PubKey {
  237.         Int2            bits;           /* bits used in modulus */
  238.         ByteStorePtr    modulus;
  239.         ByteStorePtr    exponent;
  240. } NI_PubKey, PNTR NI_PubKeyPtr;
  241.  
  242.  
  243. typedef struct NI_DispInfo {
  244.         Int4            serialno;       /* unique dispatcher serial # */
  245.         Boolean         isalternatelist;/* is this an alternate disp-list ? */
  246.         int             numdispatchers; /* number of dispachers in disp-list */
  247.         CharPtr PNTR    displist;       /* list of dispatchers */
  248.         NI_PubKeyPtr    pubKey;
  249. } NI_DispInfo, PNTR NI_DispInfoPtr;
  250.  
  251.  
  252. #endif
  253.